<template>
	<view>
		<view class="box">
			<view class="menu_content_box_page">
				<view class="pa15">

					<view class="area_block_1 pt25">

						<view class="pt25 pb25 pl20 pr20 scaley_1" v-for="item,index in databaseList" :key="index"
							@tap="toDetail(item.id)">
							<view class="flex_box">
								<view class="re mr25">
									<image :src="item.imgUrl" :lazy-load="true"  class="img17 vt" mode="aspectFill"></image>
								</view>
								<view class="item">
									<view class="df fldc jcsb hp100">
										<view class="fs28 lh34 cor_333 ell">{{item.title}}</view>
										<view class="fs22 lh26 cor_808">{{item.introduce}}</view>
										<view class="flex_box aic">
											<view class="item">
												<view class="fs30 fwb cor_F23"><text
														class="fs34">￥{{item.price}}</text></view>
											</view>
											<view class="ml5 fs22 fwb cor_808">{{item.num}}人付款</view>
										</view>
									</view>
								</view>
							</view>
						</view>

						<view v-if="databaseList.length == 0" style="width: 100%;height: 100vh;">
							<view style="height: 200rpx;"></view>
							<image :lazy-load="true" src="../../static/excavator.png" style="width: 100%; padding: 100rpx 200rpx;">
							</image>
							<view style="width: 100%;text-align: center;color: #808080;">暂无数据</view>
						</view>

					</view>
				</view>
			</view>
		</view><!-- box -->
	</view>
</template>
<script>
	import {
		toast,
		showLoading,
		hideLoading
	} from '@/utils/toast.js';
	import {
		datumPageApi,
		getTrailerFilterApi,
		getPageDatumApi
	} from '@/http/api.js';
	export default {
		data() {
			return {
				name: '',
				keywords: '',
				typeId: 0,
				databaseList: [],
				pageIndex: 1,
				pageSize: 10,
				userId: uni.getStorageSync('userId')
			}
		},
		onLoad(options) {
			if (options.name) {
				this.name = options.name;
				uni.setNavigationBarTitle({
					title: this.name
				})
			}
			if (options.keywords) {
				this.keywords = options.keywords;
				uni.setNavigationBarTitle({
					title: options.keywords
				})
			}
			if (options.typeId) {
				this.typeId = options.typeId;
			}
			this.getPageDatum();

		},
		onBackPress(options) {
		    uni.redirectTo({
		    	url: '/pages/database/database'
		    })
		},
		methods: {
			getPageDatum() {
				let that = this;
				showLoading('loading');
				getPageDatumApi({
					pageIndex: this.pageIndex,
					pageSize: this.pageSize,
					//name: this.name,
					name: this.keywords,
					typeId: this.typeId,
					userId: this.userId
				}).then(res => {
					if (res.data.data.length == that.pageSize) {
						that.pageIndex = res.data.currentPage;
					}

					for (let i in res.data.data) {
						that.databaseList.push(res.data.data[i]);
					}
					hideLoading();
				}).catch(err => {
					toast(err.msg);
					hideLoading();
				})
			},


			toDetail(id) {
				uni.navigateTo({
					url: '/pages/information_details/information_details?id=' + id
				})
			}
		}
	}
</script>

<style>
	.menu_content_box_page {
		position: relative;
		min-height: 100vh;
		background-color: #f7f6f6;
	}

	.area_block_1 {
		position: relative;
		background-color: #fff;
		border-radius: 20rpx;
	}
</style>
